package com.ittx.dzt.meituan.service;

import com.ittx.dzt.edi.dto.PlatformApiParamDTO;
import com.ittx.dzt.edi.dto.StoreConfigDTO;
import com.ittx.dzt.meituan.constant.MeituanApiConstant;
import com.ittx.dzt.meituan.handler.AbstractBaseMeituanApiHandler;
import com.ittx.dzt.sys.response.Result;
import lombok.extern.slf4j.Slf4j;
import open.dto.FlagMemoDto;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 修改备注
 * <p>
 * cy.shipment.flagUpdate
 * /api/v1/gw/order/remark/update(修改订单备注)  https://tscc.meituan.com/home/doc/bulkPurchasing/572
 * </p>
 *
 * @author gywang
 * @since 2024-08-02
 */
@Slf4j
@Service
public class MeituanMemoUpdateService extends AbstractBaseMeituanApiHandler<FlagMemoDto> {
    @Override
    public String getLocalApiMethod() {
        return open.constant.PlatformApiConstant.InboundInterface.FLAG_MEMO_UPDATE;
    }

    @Override
    public Result<?> doProcess(PlatformApiParamDTO platformApiParamDTO, FlagMemoDto flagMemoDTO) {
        StoreConfigDTO storeConfig = platformApiParamDTO.getStoreConfig();
        Map<String, String> params = new HashMap<>();
        params.put("poi_id", getPoIId(platformApiParamDTO));
        params.put("order_view_id", flagMemoDTO.getSourceOrderCode());
        params.put("poi_remark", flagMemoDTO.getMemo());
        return this.executeMeituanApi(storeConfig, params, platformApiParamDTO.getRequestId());
    }

    @Override
    public String getMeituanMethod() {
        return MeituanApiConstant.ORDER_REMARK_UPDATE;
    }

    @Override
    public String getHttpMethod() {
        return MeituanApiConstant.ApiHttpMethod.POST;
    }
}
